﻿using TiPort.TiEntityObjects;
using System.Xml.Serialization;
using TI;
using MergeTI.TiEntityObjects;
using TiEntityObject.Common;

namespace TiEntityObject.Contract
{
    public class ContractProduct
    {
        public long ContractID { get; set; }

        [XmlElement("name")]
        public string  Name {get;set;}

        public string SrchName { get {
            int l = Name.Length; 
            return Name.Substring(0,(l>400?400:l)); 
        } }

        [XmlElement("quantity")]
        public string Quantity { get; set; }

        [XmlElement("sum")]
        public string  SUM { get; set; }
        public decimal iSUM { get {
            decimal v = 0;
            decimal.TryParse(SUM, out v);
            return v;
        } }
        

        [XmlElement("price")]
        public string Price { get; set; }
        public decimal iPrice
        {
            get
            {
                decimal v = 0;
                decimal.TryParse(Price, out v);
                return v;
            }
        }

        [LinkObjectAttribute(ChildFieldName = "code", IsDictionaryValue = false, ParentFieldName = "OkdpID")]
        [XmlElement("OKDP")]
        public OKDP OKDP { get; set; }
    

        [XmlElement("OKEI")]
        [LinkObjectAttribute(ChildFieldName = "code", IsDictionaryValue = false, ParentFieldName = "OkeiID")]
        public OKEI OKEI { get; set; }

      
        [XmlElement("country")]
        [LinkObjectAttribute(ChildFieldName = "countryCode", IsPartialObject = false, ParentFieldName = "CountryID")]
        public Country Country { get; set; }

     
    }
}
